<?php
	
	$ssFilter = $this->arrParam['ssFilter'];
	
	///////////////////////////////////////////
	//-------SEARCH---------------------------
	//////////////////////////////////////////
	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort'));
	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch = $this->formSubmit('search-now','Tìm kiếm',
									array('onclick'=>"OnSubmitForm('" . $linkSearch . "')"));
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');							
	$btnResetSearch = $this->formSubmit('clear-keywords','Xóa',
									array('onclick'=>"OnSubmitForm('" . $linkResetSearch . "')"));	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;
	
	///////////////////////////////////////////
	//-------SElECTBOX GROUP ------------------
	//////////////////////////////////////////
	$linkSelect = $this->baseUrl($this->currentController . '/filter/type/slbgroup');
	$parents	= $this->cmsSelect('formSelect',$ssFilter['slbgroup'],$this->SelectGroup,
									array('style'=>'min-width:200px;',
										  'onchange'=>"OnSubmitForm('" . $linkSelect . "')"
										)
								  );
	///////////////////////////////////////////
	//-------SORT ---------------------------
	//cmsLableSort($lable,$ssFilter,$colum,$linkSort,$linkImgSort,$defaultOrder = 'DESC')
	//////////////////////////////////////////
	//http://book.local/public/templates/admin/system/images/active.png
	$linkSort	  	= $this->baseUrl($this->currentController . '/filter/type/order');
	$lblName 		= $this->cmsLableSort('Tên sách',$ssFilter,'p.name',$linkSort,$this->imgUrl );
	$lblSpecial 	= $this->cmsLableSort('Đặc biệt',$ssFilter,'p.special',$linkSort,$this->imgUrl );
	$lblOrder 	  	= $this->cmsLableSort('Giá trị',$ssFilter,'p.order',$linkSort,$this->imgUrl );
	$lblStatus 	    = $this->cmsLableSort('Trạng thái',$ssFilter,'p.status',$linkSort,$this->imgUrl);
	$lblPrice 	  	= $this->cmsLableSort('Giá Bìa',$ssFilter,'p.price',$linkSort,$this->imgUrl );
	$lblSelloff 	= $this->cmsLableSort('Giá Bán',$ssFilter,'p.selloff',$linkSort,$this->imgUrl );
	$lblAuthor 	    = $this->cmsLableSort('Tác giả',$ssFilter,'p.author',$linkSort,$this->imgUrl );
	$lblCategory    = $this->cmsLableSort('Mục',$ssFilter,'category_name',$linkSort,$this->imgUrl );
	$lblID    		= $this->cmsLableSort('ID',$ssFilter,'p.id',$linkSort,$this->imgUrl );
	
	
?>
<form name="appForm" method="post" action="">



                        <?php echo $this->render('admin-product/toolbar/index.php')?>
                        <div class="clr"></div>
                         <?php echo $this->render('admin-product/sublink/index.php')?>
                        <!-- BEGIN: CONTENT -->
                        <div id="element-box">
                            <div class="t">
                                <div class="t">
                                    <div class="t"></div>
                                </div>
                                
                            </div>
                            <div class="m">
                            	<div class = "filter">
                            		<div><?php echo $strSearch;?>
                            			<span  style="float:right;">
												<?php echo $parents;?>
										</span>
                            		</div>
                            	</div>
                            	
                             <!-- BEGIN: ELEMENT BOX -->
							 <!-- Area 4: In du lieu lay tu database -->
                                <table class="adminlist">
                                    <thead>
                                        <tr>
                                            <th width="5" ><input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()">
                                            </th>
                                            <th width="5"><?php echo $lblName;?></th>
                                            <th width="100">Picture</th>
                                            <th width="10"><?php echo $lblSpecial;?></th>
                                             <th width="1"><?php echo $lblStatus;?></th>
                                            <th width="20"><?php echo $lblPrice;?></th>						
                                            <th width="20"><?php echo $lblSelloff;?></th>
                                            <th width="34"><?php echo $lblAuthor;?></th>                                            
                                            <th width="34"><?php echo $lblOrder;?></th>                                            
                                            <th width="1">Control</th>
                                            <th width="30"><?php echo $lblCategory;?></th>
                                            <th width="30"><?php echo $lblID;?></th>
                                        </tr>
                                    </thead>
									<?php 
									if(count($this->Items)>0){
										foreach($this->Items as $key => $val){
											$id 			= $val['id'];
											$name 			= $val['name'];
											$linkPicture    = PUBLIC_URL.'/files/product/img82x122/'.$val['picture'];
											$picture 		= '<image src="'.$linkPicture.'" title="'.$name.'" width="82px" height="122px"/>';
											$author 		= $val['author'];											
											$selloff 		= $val['selloff'];
											$price 			= $val['price'];
											$category_name 	= $val['category_name'];											
											$status 		= $val['status'];
											if($status ==1){
												//cmsIconButton($title ='',$linkImg, $link = null )
												$linkStatus  = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id);
												$status = $this->cmsIconButton('Kích hoạt',$this->imgUrl.'/active.png',$linkStatus); 
											}else{
												$linkStatus  = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id);
												$status = $this->cmsIconButton('Không kích hoạt',$this->imgUrl.'/inactive.png',$linkStatus); 
											}
											
											$special 	= $val['special'];
											if($special ==1){
												//cmsIconButton($title ='',$linkImg, $link = null )
												$special = $this->cmsIconButton('Đặc biệt',$this->imgUrl.'/active.png');
											}else{
												$special = $this->cmsIconButton('Không đặc biệt',$this->imgUrl.'/inactive.png');
											}
											$order 			= $this->formText('order['.$val['id'].']',$val['order'],array('style'=>'width: 30px; text-align: center;'));
											
											$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id);
											$btnInfo		= $this->cmsIconButton('Xem',$this->imgUrl.'/icon_info.png',$linkInfo);
											
											$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id);
											$btnEdit		= $this->cmsIconButton('Sửa',$this->imgUrl.'/icon_edit.png',$linkEdit);
											
											$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id);
											$btnDelete		= $this->cmsIconButton('Xóa',$this->imgUrl.'/icon_del.png',$linkDelete);
											
											$strIconButton = $btnInfo.' '.$btnEdit.' '.$btnDelete;
											$cid		   = $this->formCheckbox('cid[]',$val['id']);
										
									?>
                                    <tr class="even">						
                                        <td align="center"><?php echo $cid;?></td>
                                        <td ><?php echo $name;?></td>
                                        <td align="center"><?php echo $picture;?></td>
                                        <td align="center"><?php echo $special;?></td>
                                        <td align="center"><?php echo $status;?></td>
                                        <td align="center"><?php echo $price .   ' VNĐ';?></td>
                                        <td align="center"><?php echo $selloff . ' VNĐ';?></td>
                                        <td align="center"><?php echo $author;?></td>
                                        <td align="center"><?php echo $order;?></td>
                                        <td align="center"><?php echo $strIconButton;?></td>
                                        <td align="center"><?php echo $category_name;?></td>
                                        <td align="center"><?php echo $id;?></td>
                                    </tr>
                                    <?php 
										}}
                                    ?>
                                    <!-- BEGIN: PAGINATION (FOOT) -->
                                    <tfoot>
                                        <tr>
                                            <td colspan="9">
                                                <div class="container">
                                                    <div class="pagination">
                                                    <?php 
                                                       $currentUrl = $this->baseUrl($this->currentController . '/index');
                                                        echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl));
                                                        ?>
                                                      
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>					
                                    </tfoot>				
                                    <!-- END: PAGINATION (FOOT) -->
                                </table>
                                <!-- Area 4: In du lieu lay tu database - End -->

                                <!-- END: ELEMENT BOX -->	
                              <div class="clr"></div>
                            </div>
                            <div class="b">
                                <div class="b">
                                    <div class="b"></div>
                                </div>
                            </div>
                        </div>
                        <!-- END: 	CONTENT -->
                    </form>